package com.xuzhiguang.baidu.pan.sdk.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Map;

/**
 * @author xuzhiguang
 * @date 2020/6/26 18:07
 */
public class BeanUtil {

    private static final ObjectMapper mapper = new ObjectMapper();

    /**
     * bean转为map
     * @param obj
     * @return
     */
    public static Map<String, String> beanToMap(Object obj) throws JsonProcessingException {
        Map<String, String> map = mapper.readValue(mapper.writeValueAsString(obj), Map.class);
        return map;
    }
}
